package com.medvalley.tcm.controller;

import com.medvalley.tcm.base.Result;
import com.medvalley.tcm.pojo.PulseDataPojo;
import com.medvalley.tcm.pojo.PulsePojo;
import com.medvalley.tcm.service.IDiagnosisDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "脉象相关接口")
public class PulseController extends BaseController {

    @Autowired
    private IDiagnosisDataService diagnosisDataService;

    @ApiOperation(value = "上传脉象数据")
    @RequestMapping(value = "/pulse/save", method = RequestMethod.POST)
    public Result savePulse(@ModelAttribute PulsePojo pulsePojo) {
        diagnosisDataService.savePulse(pulsePojo);
        return success("", pulsePojo);
    }

    @ApiOperation(value = "更新脉象数据")
    @RequestMapping(value = "/pulse/update", method = RequestMethod.POST)
    public Result updatePulse(@ModelAttribute PulsePojo pulsePojo) {
        diagnosisDataService.updatePulse(pulsePojo);
        return success("", pulsePojo);
    }


    @ApiOperation(value = "上传单次脉象数据")
    @RequestMapping(value = "/pulseData/save", method = RequestMethod.POST)
    public Result savePulseData(@ModelAttribute PulseDataPojo pulseDataPojo) {
        diagnosisDataService.savePulseData(pulseDataPojo);
        return success("", pulseDataPojo);
    }

    @ApiOperation(value = "更新单次脉象数据")
    @RequestMapping(value = "/pulseData/update", method = RequestMethod.POST)
    public Result updatePulseData(@ModelAttribute PulseDataPojo pulseDataPojo) {
        diagnosisDataService.updatePulseData(pulseDataPojo);
        return success("", pulseDataPojo);
    }

    @ApiOperation(value = "获取脉象数据")
    @RequestMapping(value = "/pulse/get", method = RequestMethod.POST)
    public Result getPulse(@RequestParam long id) {
        PulsePojo pulsePojo = diagnosisDataService.getPulseById(id);
        return success("", pulsePojo);
    }

}
